# coding:utf8
'''
    run.py
    create by kaito
    2018-01-27
    flask_restful
    PyMongo
'''
from flask import Flask
from flask_restful import Api
from _app.user import User, Password, Verificat, UserPsnAclt
from _app.web import CodeImg, Product, Promotional, ProductSerialNumber, GetDict, UploadImg, HotCommend, userIPLocation
from _app.admin import Admin, Role, Power, AUser
from _app.cart import Cart
from _app.agent import Agent
from _app.video import Video
from _app.news import News
from _app.order import Order
from _app.page import PageManage
from flask_cors import CORS

app = Flask(__name__)
api = Api(app)
CORS(app)

#api
api.add_resource(User,'/api/v3/u/u')
api.add_resource(Password,'/api/v3/u/pwd')
api.add_resource(Verificat,'/api/v3/u/v')
api.add_resource(CodeImg,'/api/v3/w/ci')
api.add_resource(Product,'/api/v3/w/p')
api.add_resource(Promotional,'/api/v3/w/ptl')
api.add_resource(ProductSerialNumber,'/api/v3/w/psn')
api.add_resource(UserPsnAclt, '/api/v3/w/upa')
api.add_resource(Order, '/api/v3/o/od')
api.add_resource(Admin,'/api/v3/a/a')
api.add_resource(Role,'/api/v3/a/r')
api.add_resource(Cart,'/api/v3/cart')
api.add_resource(Agent,'/api/v3/agt')
api.add_resource(Video,'/api/v3/video')
api.add_resource(News,'/api/v3/news')
api.add_resource(Power, '/api/v3/a/power')
api.add_resource(AUser, '/api/v3/a/au')
api.add_resource(GetDict, '/api/v3/w/dict')
api.add_resource(UploadImg, '/api/v3/w/upload')
api.add_resource(HotCommend, '/api/v3/w/hc')
api.add_resource(PageManage, '/api/v3/page')
api.add_resource(userIPLocation, '/api/v3/ip')
# run
if __name__ == '__main__':
    print ('server is running...')
    app.run(debug=True,host='127.0.0.1',port=8080)

